package com.wangwenjun.concurrency.chapter17;

import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.LockSupport;
import java.util.concurrent.locks.ReentrantLock;

/**
 *
 * 1.LockSupport.unpark(thread);
 * 2.LockSupport.park();
 * thread线程不会阻塞
 *
 */
public class TaoBaoTest10 {

    static Thread t1 = null;
    static Thread t2 = null;
    static Thread t3 = null;

    public static void main(String[] args) throws InterruptedException {


        t1 = new Thread(() -> {
            for (int i = 0; i < 3; i++) {
                LockSupport.park();
                System.out.println("a");
                LockSupport.unpark(t2);
            }
        }, "t1");

        t2 = new Thread(() -> {
            for (int i = 0; i < 3; i++) {
                LockSupport.park();
                System.out.println("b");
                LockSupport.unpark(t3);
            }
        }, "t2");

        t3 = new Thread(() -> {
            for (int i = 0; i < 3; i++) {
                LockSupport.park();
                System.out.println("c");
                LockSupport.unpark(t1);
            }

        }, "t3");


        t1.start();
        t2.start();
        t3.start();

        LockSupport.unpark(t1);



    }









}
